package com.geo.geotool.entity.sql;

import lombok.Data;
import org.apache.ibatis.jdbc.SQL;

import java.util.Map;

/**
 * • @Description: 要素增加实体
 * • @author  : yell
 * • @date : 2021/11/18  15:28
 */
@Data
public class SFeatureEntity implements IFeatureSQL {
    private Map<String,Object> attributes;
    private String geom;
    private String layerName;
    private String srId = "4490";
    @Override
    public String buildFeatureSQL() {
        return new SQL(){
            {
                INSERT_INTO(layerName);
                for(String key : attributes.keySet()){
                    VALUES(key,"'"+String.valueOf(attributes.get(key))+"'");
                }
                VALUES("the_geom","st_setsrid(st_GeomFromGeoJSON('"+geom+"'),"+srId+")");
            }
        }.toString();
    }
}
